package com.huawei.classroom.student.h05;

public class RifleSoldier extends Soldier{
	public RifleSoldier() {
		health=50;
		force=5;
		LivingSoldierCount++;
	}
	
	@Override
	public void attack(Role object) {
		if(object.health<=0) {
			System.out.println("Object had died, attacking failed");
			return;
		}
		
			if(object instanceof Dog) {//心疼狗
				object.health=0;
			}
			else object.health-=force;
			
			System.out.println("Attack successful");
			//判断死亡的是不是士兵，因为要统计人数
			if(object.health<=0 && (object instanceof Soldier)) {
				Soldier.LivingSoldierCount--;
				Soldier.DeadedSoldierCount++;
			}
		
	}
}
